package demo.javassist.ibmdemo;

/**
 * https://www.ibm.com/developerworks/cn/java/j-dyn0916/
 * 1) 执行这个例子程序是在cmd下测试的，将java代码和package目录一起复制到G:\test目录下
 * 2) javac 编译两个文件
 * 3) java  运行
 * 4) 费了一番周折,最终是测试成功,过程记录在印象笔记"2017年12月20日： javassist | 学习笔记"
 * 
 * @author Wxg
 *
 */
public class StringBuilder {

	private String buildString(int length){
//		long start = System.currentTimeMillis();
		String result = "";
		for (int i=0; i<length; i++){
			result += (char)(i%26 + 'a');
		}
//		System.out.println("Call to buildString took " + (System.currentTimeMillis()-start) + " ms.");
		return result;
	}
	
	public static void main(String[] args) {
		StringBuilder inst = new StringBuilder();
		String[] arr = new String[]{"100000", "200000"};
		arr = args;
		for(int i=0;i<arr.length;i++){
			String result = inst.buildString(Integer.parseInt(arr[i]));
			System.out.println("Constructed string of length " + result.length());
		}
	}
}
